/*!
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * 项目自定义的公共JavaScript，可覆盖jeesite.js里的方法
 */

function  getCurrentWin(){
    var tabPage = js.tabPage && js.tabPage.getCurrentTabPage();
    if(!tabPage || tabPage.length === 0) return window;
    return tabPage[0].contentWindow;
}

js.curWin = getCurrentWin();

//在页面内打开弹出框
function openLayerPage(url, title, width, height) {
    js.layer.open({
        type: 2,
        maxmin: true,
        shadeClose: true,
        title: title,
        area: [width + 'px', height + 'px'],
        content: url
    });
}

function getDisplayText(dataList, valueKey, displayKey, value, defaultValue){
    var result = [];
    for (var i = 0; i < dataList.length; i++) {
        var row = dataList[i];
        if (("," + value + ",").indexOf("," + row[valueKey] + ",") != -1) {
            result.push(row[displayKey])
        }
    }
    return result.length > 0 ? result.join(",") : defaultValue
}